home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / drivers / stadhero.c < prev    next >
C/C++ Source or Header  |  2000-04-23  |  12KB  |  397 lines

  1. /***************************************************************************
  2.  
  3.     Stadium Hero (Japan)            (c) 1988 Data East Corporation
  4.  
  5.     Emulation by Bryan McPhail, mish@tendril.co.uk
  6.  
  7. ***************************************************************************/
  8.  
  9. #include "driver.h"
  10. #include "vidhrdw/generic.h"
  11. #include "cpu/m6502/m6502.h"
  12.  
  13. /* Video emulation definitions */
  14. int  stadhero_vh_start(void);
  15. void stadhero_vh_stop(void);
  16. void stadhero_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);
  17.  
  18. extern unsigned char *stadhero_pf1_data,*stadhero_pf2_data;
  19.  
  20. WRITE_HANDLER( stadhero_pf1_data_w );
  21. READ_HANDLER( stadhero_pf1_data_r );
  22. WRITE_HANDLER( stadhero_pf2_control_0_w );
  23. WRITE_HANDLER( stadhero_pf2_control_1_w );
  24. WRITE_HANDLER( stadhero_pf2_data_w );
  25. READ_HANDLER( stadhero_pf2_data_r );
  26.  
  27. /******************************************************************************/
  28.  
  29. static READ_HANDLER( stadhero_control_r )
  30. {
  31.     switch (offset)
  32.     {
  33.         case 0: /* Player 1 & 2 joystick & buttons */
  34.             return (readinputport(0) + (readinputport(1) << 8));
  35.  
  36.         case 2: /* Credits, start buttons */
  37.             return readinputport(2) | (readinputport(2)<<8);
  38.  
  39.         case 4: /* Byte 4: Dipswitch bank 2, Byte 5: Dipswitch Bank 1 */
  40.             return (readinputport(3) + (readinputport(4) << 8));
  41.     }
  42.  
  43.     logerror("CPU #0 PC %06x: warning - read unmapped memory address %06x\n",cpu_get_pc(),0x30c000+offset);
  44.     return 0xffff;
  45. }
  46.  
  47. static WRITE_HANDLER( stadhero_control_w )
  48. {
  49.     switch (offset)
  50.     {
  51.         case 4: /* Interrupt ack (VBL - IRQ 5) */
  52.             break;
  53.         case 6: /* 6502 sound cpu */
  54.             soundlatch_w(0,data & 0xff);
  55.             cpu_cause_interrupt(1,M6502_INT_NMI);
  56.             break;
  57.         default:
  58.             logerror("CPU #0 PC %06x: warning - write %02x to unmapped memory address %06x\n",cpu_get_pc(),data,0x30c010+offset);
  59.             break;
  60.     }
  61. }
  62.  
  63. static WRITE_HANDLER( spriteram_mirror_w )
  64. {
  65.     WRITE_WORD(&spriteram[offset],data);
  66. }
  67.  
  68. /******************************************************************************/
  69.  
  70. static struct MemoryReadAddress stadhero_readmem[] =
  71. {
  72.     { 0x000000, 0x01ffff, MRA_ROM },
  73.     { 0x200000, 0x2007ff, stadhero_pf1_data_r },
  74.     { 0x260000, 0x261fff, stadhero_pf2_data_r },
  75.     { 0x30c000, 0x30c00b, stadhero_control_r },
  76.     { 0x310000, 0x3107ff, paletteram_word_r },
  77.     { 0xff8000, 0xffbfff, MRA_BANK1 }, /* Main ram */
  78.     { 0xffc000, 0xffc7ff, MRA_BANK2 }, /* Sprites */
  79.     { -1 }  /* end of table */
  80. };
  81.  
  82. static struct MemoryWriteAddress stadhero_writemem[] =
  83. {
  84.     { 0x000000, 0x01ffff, MWA_ROM },
  85.     { 0x200000, 0x2007ff, stadhero_pf1_data_w, &stadhero_pf1_data },
  86.     { 0x240000, 0x240007, stadhero_pf2_control_0_w },
  87.     { 0x240010, 0x240017, stadhero_pf2_control_1_w },
  88.     { 0x260000, 0x261fff, stadhero_pf2_data_w, &stadhero_pf2_data },
  89.     { 0x30c000, 0x30c00b, stadhero_control_w },
  90.     { 0x310000, 0x3107ff, paletteram_xxxxBBBBGGGGRRRR_word_w, &paletteram },
  91.     { 0xff8000, 0xffbfff, MWA_BANK1 },
  92.     { 0xffc000, 0xffc7ff, MWA_BANK2, &spriteram },
  93.     { 0xffc800, 0xffcfff, spriteram_mirror_w },
  94.     { -1 }  /* end of table */
  95. };
  96.  
  97. /******************************************************************************/
  98.  
  99. static WRITE_HANDLER( YM3812_w )
  100. {
  101.     switch (offset) {
  102.     case 0:
  103.         YM3812_control_port_0_w(0,data);
  104.         break;
  105.     case 1:
  106.         YM3812_write_port_0_w(0,data);
  107.         break;
  108.     }
  109. }
  110.  
  111. static WRITE_HANDLER( YM2203_w )
  112. {
  113.     switch (offset) {
  114.     case 0:
  115.         YM2203_control_port_0_w(0,data);
  116.         break;
  117.     case 1:
  118.         YM2203_write_port_0_w(0,data);
  119.         break;
  120.     }
  121. }
  122.  
  123. static struct MemoryReadAddress stadhero_s_readmem[] =
  124. {
  125.     { 0x0000, 0x05ff, MRA_RAM },
  126.     { 0x3000, 0x3000, soundlatch_r },
  127.     { 0x3800, 0x3800, OKIM6295_status_0_r },
  128.     { 0x8000, 0xffff, MRA_ROM },
  129.     { -1 }  /* end of table */
  130. };
  131.  
  132. static struct MemoryWriteAddress stadhero_s_writemem[] =
  133. {
  134.     { 0x0000, 0x05ff, MWA_RAM },
  135.     { 0x0800, 0x0801, YM2203_w },
  136.     { 0x1000, 0x1001, YM3812_w },
  137.     { 0x3800, 0x3800, OKIM6295_data_0_w },
  138.     { 0x8000, 0xffff, MWA_ROM },
  139.     { -1 }  /* end of table */
  140. };
  141.  
  142. /******************************************************************************/
  143.  
  144. INPUT_PORTS_START( stadhero )
  145.     PORT_START    /* Player 1 controls */
  146.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_8WAY )
  147.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_8WAY )
  148.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_8WAY )
  149.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY )
  150.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 )
  151.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 )
  152.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 )
  153.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START1 )
  154.  
  155.     PORT_START    /* Player 2 controls */
  156.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_8WAY | IPF_PLAYER2 )
  157.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_8WAY | IPF_PLAYER2 )
  158.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_8WAY | IPF_PLAYER2 )
  159.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER2 )
  160.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2 )
  161.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER2 )
  162.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 | IPF_PLAYER2 )
  163.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START2 )
  164.  
  165.     PORT_START    /* Credits, start buttons */
  166.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
  167.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
  168.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_START1 )
  169.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_START2 )
  170.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_COIN1 )
  171.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN2 )
  172.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN3 ) /* Service */
  173.     PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_VBLANK )
  174.  
  175.     PORT_START    /* Dip switch bank 1 */
  176.     PORT_DIPNAME( 0x03, 0x03, DEF_STR( Coin_A ) )
  177.     PORT_DIPSETTING(    0x00, DEF_STR( 3C_1C ) )
  178.     PORT_DIPSETTING(    0x01, DEF_STR( 2C_1C ) )
  179.     PORT_DIPSETTING(    0x03, DEF_STR( 1C_1C ) )
  180.     PORT_DIPSETTING(    0x02, DEF_STR( 1C_2C ) )
  181.     PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Coin_B ) )
  182.     PORT_DIPSETTING(    0x00, DEF_STR( 3C_1C ) )
  183.     PORT_DIPSETTING(    0x04, DEF_STR( 2C_1C ) )
  184.     PORT_DIPSETTING(    0x0c, DEF_STR( 1C_1C ) )
  185.     PORT_DIPSETTING(    0x08, DEF_STR( 1C_2C ) )
  186.     PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
  187.     PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
  188.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  189.     PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
  190.     PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
  191.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  192.     PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
  193.     PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
  194.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  195.     PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
  196.     PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
  197.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  198.  
  199.     PORT_START    /* Dip switch bank 2 */
  200.     PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) )
  201.     PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
  202.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  203.     PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) )
  204.     PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
  205.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  206.     PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )
  207.     PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
  208.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  209.     PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
  210.     PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
  211.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  212.     PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
  213.     PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
  214.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  215.     PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
  216.     PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
  217.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  218.     PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
  219.     PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
  220.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  221.     PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
  222.     PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
  223.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  224. INPUT_PORTS_END
  225.  
  226. /******************************************************************************/
  227.  
  228. static struct GfxLayout charlayout =
  229. {
  230.     8,8,    /* 8*8 chars */
  231.     4096,
  232.     3,        /* 4 bits per pixel  */
  233.     { 0x00000*8,0x8000*8,0x10000*8 },
  234.     { 0, 1, 2, 3, 4, 5, 6, 7 },
  235.     { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
  236.     8*8    /* every char takes 8 consecutive bytes */
  237. };
  238.  
  239. static struct GfxLayout tile_3bpp =
  240. {
  241.     16,16,
  242.     2048,
  243.     3,
  244.     { 0x20000*8, 0x10000*8, 0x00000*8 },
  245.     { 16*8+0, 16*8+1, 16*8+2, 16*8+3, 16*8+4, 16*8+5, 16*8+6, 16*8+7,
  246.             0, 1, 2, 3, 4, 5, 6, 7 },
  247.     { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8,
  248.             8*8, 9*8, 10*8, 11*8, 12*8, 13*8, 14*8, 15*8 },
  249.     16*16
  250. };
  251.  
  252. static struct GfxLayout spritelayout =
  253. {
  254.     16,16,
  255.     4096,
  256.     4,
  257.     { 0x60000*8,0x40000*8,0x20000*8,0x00000*8 },
  258.     { 16*8+0, 16*8+1, 16*8+2, 16*8+3, 16*8+4, 16*8+5, 16*8+6, 16*8+7,
  259.             0, 1, 2, 3, 4, 5, 6, 7 },
  260.     { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8,
  261.             8*8, 9*8, 10*8, 11*8, 12*8, 13*8, 14*8, 15*8 },
  262.     16*16
  263. };
  264.  
  265. static struct GfxDecodeInfo gfxdecodeinfo[] =
  266. {
  267.     { REGION_GFX1, 0, &charlayout,     0, 16 },    /* Characters 8x8 */
  268.     { REGION_GFX2, 0, &tile_3bpp,    512, 16 },    /* Tiles 16x16 */
  269.     { REGION_GFX3, 0, &spritelayout, 256, 16 },    /* Sprites 16x16 */
  270.     { -1 } /* end of array */
  271. };
  272.  
  273. /******************************************************************************/
  274.  
  275. static void irqhandler(int linestate)
  276. {
  277.     cpu_set_irq_line(1,0,linestate);
  278. }
  279.  
  280. static struct YM2203interface ym2203_interface =
  281. {
  282.     1,
  283.     1500000,    /* 12MHz clock divided by 8 = 1.50 MHz */
  284.     { YM2203_VOL(40,95) },
  285.     { 0 },
  286.     { 0 },
  287.     { 0 },
  288.     { 0 }
  289. };
  290.  
  291. static struct YM3812interface ym3812_interface =
  292. {
  293.     1,            /* 1 chip */
  294.     3000000,    /* 3 MHz (12MHz/4) */
  295.     { 40 },
  296.     { irqhandler },
  297. };
  298.  
  299. static struct OKIM6295interface okim6295_interface =
  300. {
  301.     1,              /* 1 chip */
  302.     { 7757 },           /* 8000Hz frequency */
  303.     { REGION_SOUND1 },    /* memory region 3 */
  304.     { 80 }
  305. };
  306.  
  307. /******************************************************************************/
  308.  
  309. static struct MachineDriver machine_driver_stadhero =
  310. {
  311.     /* basic machine hardware */
  312.     {
  313.         {
  314.             CPU_M68000,
  315.             10000000,
  316.             stadhero_readmem,stadhero_writemem,0,0,
  317.             m68_level5_irq,1 /* VBL */
  318.         },
  319.         {
  320.             CPU_M6502 | CPU_AUDIO_CPU,
  321.             1500000,
  322.             stadhero_s_readmem,stadhero_s_writemem,0,0,
  323.             ignore_interrupt,0
  324.         }
  325.     },
  326.     58, 529,
  327.     1,    /* 1 CPU slice per frame - interleaving is forced when a sound command is written */
  328.     0,
  329.  
  330.     /* video hardware */
  331.     32*8, 32*8, { 0*8, 32*8-1, 1*8, 31*8-1 },
  332.  
  333.     gfxdecodeinfo,
  334.     1024, 1024,
  335.     0,
  336.  
  337.     VIDEO_TYPE_RASTER | VIDEO_MODIFIES_PALETTE,
  338.     0,
  339.     stadhero_vh_start,
  340.     stadhero_vh_stop,
  341.     stadhero_vh_screenrefresh,
  342.  
  343.     /* sound hardware */
  344.     0,0,0,0,
  345.     {
  346.         {
  347.             SOUND_YM2203,
  348.             &ym2203_interface
  349.         },
  350.         {
  351.             SOUND_YM3812,
  352.             &ym3812_interface
  353.         },
  354.         {
  355.             SOUND_OKIM6295,
  356.             &okim6295_interface
  357.         }
  358.     }
  359. };
  360.  
  361. /******************************************************************************/
  362.  
  363. ROM_START( stadhero )
  364.     ROM_REGION( 0x20000, REGION_CPU1 )    /* 6*64k for 68000 code */
  365.     ROM_LOAD_EVEN( "ef15.bin",  0x00000, 0x10000, 0xbbba364e )
  366.     ROM_LOAD_ODD ( "ef13.bin",  0x00000, 0x10000, 0x97c6717a )
  367.  
  368.     ROM_REGION( 0x10000, REGION_CPU2 )    /* 6502 Sound */
  369.     ROM_LOAD( "ef18.bin",  0x8000, 0x8000, 0x20fd9668 )
  370.  
  371.     ROM_REGION( 0x18000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  372.     ROM_LOAD( "ef08.bin",     0x000000, 0x10000, 0xe84752fe )    /* chars */
  373.     ROM_LOAD( "ef09.bin",     0x010000, 0x08000, 0x2ade874d )
  374.  
  375.     ROM_REGION( 0x30000, REGION_GFX2 | REGIONFLAG_DISPOSE )
  376.     ROM_LOAD( "ef10.bin",     0x000000, 0x10000, 0xdca3d599 )    /* tiles */
  377.     ROM_LOAD( "ef11.bin",     0x010000, 0x10000, 0xaf563e96 )
  378.     ROM_LOAD( "ef12.bin",     0x020000, 0x10000, 0x9a1bf51c )
  379.  
  380.     ROM_REGION( 0x80000, REGION_GFX3 | REGIONFLAG_DISPOSE )
  381.     ROM_LOAD( "ef00.bin",     0x000000, 0x10000, 0x94ed257c )    /* sprites */
  382.     ROM_LOAD( "ef01.bin",     0x010000, 0x10000, 0x6eb9a721 )
  383.     ROM_LOAD( "ef02.bin",     0x020000, 0x10000, 0x850cb771 )
  384.     ROM_LOAD( "ef03.bin",     0x030000, 0x10000, 0x24338b96 )
  385.     ROM_LOAD( "ef04.bin",     0x040000, 0x10000, 0x9e3d97a7 )
  386.     ROM_LOAD( "ef05.bin",     0x050000, 0x10000, 0x88631005 )
  387.     ROM_LOAD( "ef06.bin",     0x060000, 0x10000, 0x9f47848f )
  388.     ROM_LOAD( "ef07.bin",     0x070000, 0x10000, 0x8859f655 )
  389.  
  390.     ROM_REGION( 0x10000, REGION_SOUND1 )    /* ADPCM samples */
  391.     ROM_LOAD( "ef17.bin",  0x0000, 0x10000, 0x07c78358 )
  392. ROM_END
  393.  
  394. /******************************************************************************/
  395.  
  396. GAME( 1988, stadhero, 0, stadhero, stadhero, 0, ROT0, "Data East Corporation", "Stadium Hero (Japan)" )
  397.